//产品跟踪
Vue.component('product_trade_trackings', {
	template: '<div class="track">\
					<div class="one_news overflow cursor" @click="show_track_detail(item)" v-for="(item,index) in notices">\
						<div>{{index+1}}</div>\
						<div>\
							<div class="overflow">\
								<li class="money">{{item.CustomerName}}</li>\
								<li>{{item.Sex?"男":"女"}}</li>\
								<li>{{item.Age}}岁</li>\
								<li>{{item.Address}}</li>\
								<li>{{item.Career}}</li>\
							</div>\
							<div>\
								备注：{{item.Remark}}\
							</div>\
						</div>\
					</div>\
					<!--<change-page :current_page="page.pageIndex" :page_size="page.pageSize" :page_total="page.pageTotal" @page-change="getProductTradeTrackings"></change-page>-->\
					<div class="letters_detail" v-show="letters_detail_show">\
							<button  type="button" class="btn btn-base back_list" style="width:auto;" @click="letters_detail_show=false">返回案例追踪</button>\
							<div>\
								<div class="one_detail" v-for="(item,index) in details">\
									<div>\
										<span class="money">{{item.Title}}</span>\
									</div>\
									<div>\
										<span>{{item.Content}}</span>\
									</div>\
									<div>\
										<span class="time">{{item.CreateTimeText}}</span>\
									</div>\
								</div>\
							</div>\
						</div>\
				</div>',
	data: function() {
		return {
			url: {
				getProductTradeTrackings: '/api/SiteMessage/GetProductTradeTrackings',
				getDetail:'/api/SiteMessage/GetSiteMessagesByCustomer'
			},
			notices: [],
			details:[],
			letters_detail_show:false,
			page: {
				pageIndex: 1,
				pageSize: 100,
				pageTotal: 0
			}
		}
	},
	mounted: function() {
		this.getProductTradeTrackings(this.page.pageIndex, this.page.pageSize);
	},
	methods: {
		//获取列表
		getProductTradeTrackings: function(curPage, pageSize) {
			var that = this;
			var data = {
				PageIndex: curPage,
				PageSize: pageSize
			};
			globalData.ajaxPost(this.url.getProductTradeTrackings, data, function(res) {
				var d = res.data;
				d = globalData.utils.notNullDefaulst(d,[]);
				globalData.utils.page(that, curPage, res.count);
				that.notices = d;
			})
		},
		//获取详情
		getDetail:function(id){
			var that = this;
			var data ={ CustomerID:id};
			globalData.ajaxPost(this.url.getDetail, data, function(res) {
				var d = res.data;
				d = globalData.utils.notNullDefaulst(d,[]);
				globalData.utils.page(that, that.page.curPage, res.count);
				that.details = d;
			})
		},
		//显示详情
		show_track_detail:function(item){
			console.log(item)
			this.getDetail(item.CustomerID);
			this.letters_detail_show = true;
		},
		//展开所有
		slideDown_up: function(ev, targetClass) {
			var dom = $(ev.target)
			var targetDom = globalData.utils.get_target_dom(dom, targetClass)
			if(targetDom.hasClass('active')) {
				targetDom.removeClass('active')
			} else {
				targetDom.addClass('active')
			}
		},
	}
});